﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class WebConsultaGeneral : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Id = (String)Session["IdCliente"]; 
        cargarCuotas();
    }
    
    GestionDatos.Service aux = new GestionDatos.Service();
    System.Data.DataSet ds = new System.Data.DataSet();
    String SQL, Id;
    String messa = "";
    
    void cargarGrid(System.Data.DataSet dsTabla) 
        {
            GridView1.DataSource = dsTabla.Tables[0].DefaultView; 
            GridView1.DataBind();
        }

    void cargarCuotas() 
        {
        SQL = "Select Fecha_Cuota, Monto_Cuota As Cuota,"; 
        SQL += "Descripcion From tbCuotas Where AsociadoID = '" + Id.Trim() +"'"; // error del trim
        aux.obtenerDatos(ref messa, SQL, ref ds); 
        cargarGrid(ds); 
        }


    protected void BtnConsultar_Click(object sender, EventArgs e)
    {
        String Fecha1, Fecha2; 
        Fecha1 = DatePicker2.SelectedDate.ToString(); 
        Fecha2 = DatePicker3.SelectedDate.ToString(); 
        //DatePicker1.PickerFormat = "MM/dd/yyyy"; 
        SQL = "Select Fecha_Cuota As Fecha, Monto_Cuota As Cuota,"; 
        SQL += "Descripcion From tbCuotas Where AsociadoID = '" + Id.Trim() + "'"; 
        SQL += " And Fecha_Cuota >='" + Fecha1 + "' And Fecha_Cuota <='" + Fecha2 + "'"; 
        ds.Clear(); 
        aux.obtenerDatos(ref messa, SQL, ref ds); 
        cargarGrid(ds);
    }
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        int fila = Convert.ToInt32(GridView1.SelectedIndex); 
        Label1.Text = GridView1.Rows[fila].Cells[1].Text;
        Label2.Text = GridView1.Rows[fila].Cells[2].Text; 
        Label3.Text = GridView1.Rows[fila].Cells[3].Text;
    }
}